package org.atlantis.netty.decoder;

import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.codec.oneone.OneToOneDecoder;

/**
 * 尝试OneToOneDecoder，和文档上说的OneToOneDecoder必须有一个FrameDecoder不同的是：
 * 其实OneToOneDecoder完全可以单独使用，不需要FrameDecoder。
 * 
 * @author xi_li
 */
public class SimpleOnetoOneDecoder extends OneToOneDecoder {

	@Override
	protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
		ChannelBuffer buffer = (ChannelBuffer) msg;
		System.out.println(new String(buffer.toByteBuffer().array()));
		return null;
	}
}
